package com.ruoyi.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.DatabaseBackup;
import com.ruoyi.system.mapper.DatabaseBackupMapper;
import com.ruoyi.system.service.IDatabaseBackupService;

/**
 * 数据库备份 服务层实现
 * 
 * @author ruoyi
 */
@Service
public class DatabaseBackupServiceImpl implements IDatabaseBackupService
{
    @Autowired
    private DatabaseBackupMapper databaseBackupMapper;

    /**
     * 查询数据库备份信息
     * 
     * @param backupId 备份ID
     * @return 数据库备份信息
     */
    @Override
    public DatabaseBackup selectDatabaseBackupById(Long backupId)
    {
        return databaseBackupMapper.selectDatabaseBackupById(backupId);
    }

    /**
     * 查询数据库备份列表
     * 
     * @param databaseBackup 数据库备份信息
     * @return 数据库备份集合
     */
    @Override
    public List<DatabaseBackup> selectDatabaseBackupList(DatabaseBackup databaseBackup)
    {
        return databaseBackupMapper.selectDatabaseBackupList(databaseBackup);
    }

    /**
     * 查询数据库的备份历史
     * 
     * @param dbId 数据库ID
     * @return 数据库备份集合
     */
    @Override
    public List<DatabaseBackup> selectDatabaseBackupByDbId(Long dbId)
    {
        return databaseBackupMapper.selectDatabaseBackupByDbId(dbId);
    }

    /**
     * 新增数据库备份
     * 
     * @param databaseBackup 数据库备份信息
     * @return 结果
     */
    @Override
    public int insertDatabaseBackup(DatabaseBackup databaseBackup)
    {
        databaseBackup.setCreateBy(SecurityUtils.getUsername());
        databaseBackup.setCreateTime(DateUtils.getNowDate());
        return databaseBackupMapper.insertDatabaseBackup(databaseBackup);
    }

    /**
     * 修改数据库备份
     * 
     * @param databaseBackup 数据库备份信息
     * @return 结果
     */
    @Override
    public int updateDatabaseBackup(DatabaseBackup databaseBackup)
    {
        databaseBackup.setUpdateBy(SecurityUtils.getUsername());
        databaseBackup.setUpdateTime(DateUtils.getNowDate());
        return databaseBackupMapper.updateDatabaseBackup(databaseBackup);
    }

    /**
     * 删除数据库备份信息
     * 
     * @param backupId 备份ID
     * @return 结果
     */
    @Override
    public int deleteDatabaseBackup(Long backupId)
    {
        return databaseBackupMapper.deleteDatabaseBackup(backupId);
    }

    /**
     * 批量删除数据库备份信息
     * 
     * @param backupIds 需要删除的备份ID
     * @return 结果
     */
    @Override
    public int deleteDatabaseBackupByIds(Long[] backupIds)
    {
        return databaseBackupMapper.deleteDatabaseBackupByIds(backupIds);
    }
} 